package org.example.domain.strategy.service.rule.tree.factory;

import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.example.domain.strategy.model.vo.RuleLogicCheckTypeVO;
import org.example.domain.strategy.model.vo.RuleTreeNodeVO;
import org.example.domain.strategy.model.vo.RuleTreeVO;
import org.example.domain.strategy.service.rule.tree.ILogicTreeNode;
import org.example.domain.strategy.service.rule.tree.factory.engine.impl.DecisionTreeEngine;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 规则树工厂    负责生成引擎对象并返回
 */
@Service
@Slf4j
public class DefaultTreeFactory {


    private final Map<String, ILogicTreeNode> groups;


    public DefaultTreeFactory(Map<String, ILogicTreeNode> groups) {
        this.groups = groups;
    }

    public DecisionTreeEngine startEngine(RuleTreeVO ruleTreeVO){

        return new DecisionTreeEngine(groups,ruleTreeVO);

    }


    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class TreeActionEntity{

        private RuleLogicCheckTypeVO ruleLogicCheckType;

        private StrategyAwardData strategyAwardData;
    }

    /**
     *
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class StrategyAwardData{

        private Integer awardId;

        private String awardRuleValue;
    }


}
